<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录测试</title>
</head>
<body>
    <h1>登录API测试</h1>
    <button onclick="testLogin()">测试登录</button>
    <div id="result"></div>

    <script>
        async function testLogin() {
            const resultDiv = document.getElementById('result');

            try {
                console.log('开始测试登录...');

                const response = await fetch('http://127.0.0.1:8089/api/v1/auth/login', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        username: 'admin',
                        password: '123456'
                    })
                });

                console.log('响应状态:', response.status);
                const data = await response.json();
                console.log('响应数据:', data);

                resultDiv.innerHTML = `
                    <h3>测试结果:</h3>
                    <p>状态码: ${response.status}</p>
                    <p>响应数据: <pre>${JSON.stringify(data, null, 2)}</pre></p>
                `;

            } catch (error) {
                console.error('登录测试失败:', error);
                resultDiv.innerHTML = `
                    <h3>测试失败:</h3>
                    <p>错误: ${error.message}</p>
                `;
            }
        }
    </script>
</body>
</html>